function Up($){
	$('html, body').animate({scrollTop:0},500);
}

$(document).ready(function(){
	$('#blocks ul').after('<div id="block-content"></div>');
	$('#blocks li').each(function(){
		if($(this).attr('class')=='active'){
			$('#block-content').html($('a',this).next().html());
		}
	});
	$('#blocks ul a').click(function(e){
		e.preventDefault();
		$(this).parent().addClass('active').siblings().removeClass('active');
		$('#block-content').html($(this).next().html());
		//alert($(this).next().html());
	});
	
	$window = $(window);
	$sticky = $("#sticky-bar");
	$Hsticky = $sticky.outerHeight();
	$btnUp = $("#btnUp");
	$menu=$('.menu');
	/*$home = $('#header').outerHeight() + $('#home-content').outerHeight()-$sticky.outerHeight();
	$our_profiles=$home+$('#what-is-seo').outerHeight();
	$seo_services=$our_profiles+$('#our-profiles').outerHeight();
	$seo_consulting=$seo_services+$('#seo-services').outerHeight();
	$contact=$seo_consulting+$('#seo-consulting').outerHeight();*/
	
	$what_is_seo=$('#what-is-seo').offset().top;
	$our_profiles=$('#our-profiles').offset().top;
	$seo_services=$('#seo-services').offset().top;
	$seo_consulting=$('#seo-consulting').offset().top;
	$seo_packages=$('#seo-packages').offset().top;
	$case_studies=$('#case-studies').offset().top;
	$contact=$('#contact').offset().top;
	
	if($.browser.webkit)
	{
		$seo_consulting+=162;
		$contact+=165;
	}
	$window.scroll(function(){
		$pos=$window.scrollTop();
		if($pos >= $what_is_seo){
			$sticky.fadeIn("fast");
			$btnUp.fadeIn("fast");
			$('a[href=#what-is-seo]').parent().addClass("active").siblings().removeClass("active");
		}else{
			$sticky.fadeOut("fast");
			$btnUp.fadeOut("fast");
		}
		
		if($pos>=$contact || $pos==($(document).height()-$window.height()))
		{
			$('a[href=#contact]').parent().addClass("active").siblings().removeClass("active");
		}else if($pos>=$seo_consulting)
		{
			$('a[href=#seo-consulting]').parent().addClass("active").siblings().removeClass("active");
		}else if($pos>=$seo_services)
		{
			$('a[href=#seo-services]').parent().addClass("active").siblings().removeClass("active");
		}else if($pos>=$our_profiles)
		{
			$('a[href=#our-profiles]').parent().addClass("active").siblings().removeClass("active");
		}else if($pos==0){
			$('a[href="#home"]').parent().addClass("active").siblings().removeClass("active");
		}
	});
	
	$btnUp.click(function(){
		$("html, body").animate({scrollTop:0},500);
	});
	
	
	
	$('a',$menu).click(function(){
		$pos=$(this).attr('href');
		switch($pos){
			case "#home":
			{
				$("html, body").animate({scrollTop:0});
				$('a[href=#home]').parent().addClass("active").siblings().removeClass("active");
				break;
			}
			case "#what-is-seo":
			{
				$("html, body").animate({scrollTop:$what_is_seo});
				$('a[href=#what-is-seo]').parent().addClass("active").siblings().removeClass("active");
				break;
			}
			case "#our-profiles":
			{
				$("html, body").animate({scrollTop:$our_profiles});
				$('a[href=#our-profiles]').parent().addClass("active").siblings().removeClass("active");
				break;
			}
			case "#seo-services":
			{
				$("html, body").animate({scrollTop:$seo_services});
				$('a[href=#seo-services]').parent().addClass("active").siblings().removeClass("active");
				break;
			}
			case "#seo-consulting":
			{
				$("html, body").animate({scrollTop:$seo_consulting});
				$('a[href=#seo-consulting]').parent().addClass("active").siblings().removeClass("active");
				break;
			}
			case "#contact":
			{
				$("html, body").animate({scrollTop:$contact});
				$('a[href=#contact]').parent().addClass("active").siblings().removeClass("active");
				break;
			}
		}
	});
});